﻿using System;
using System.Collections.Generic;
using System.Text;
using MyHotel_BUSWS.MyHotel_LoaiPhongDAO_Webservice;
using MyHotel_BUSWS.MyHotel_DanhMucPhongDAO_Webservice;
using MyHotel_BUSWS.MyHotel_PhongDAO_Webservice;


namespace MyHotel_BUSWS
{
    public class MHLapDanhMucPhongBUS
    {
        public static LoaiPhong[] getListLoaiPhong()
        {
            LoaiPhongDAOWSSoapClient ws = new LoaiPhongDAOWSSoapClient();

            return ws.getList();
        }
        public static Danhmucphong[] getListDanhMucPhong(int maloai)
        {
            DanhMucPhongDAOWSSoapClient ws = new DanhMucPhongDAOWSSoapClient();
            return ws.getListDanhMucPhong(maloai);
        }

        public static Danhmucphong[] getDanhSachDanhMucPhong()
        {
            DanhMucPhongDAOWSSoapClient ws = new DanhMucPhongDAOWSSoapClient();
            return ws.getDanhSachDanhMucPhong();
        }

        public static LoaiPhong getLoaiPhongbyMaLoai(int maloai)
        {
            LoaiPhongDAOWSSoapClient ws = new LoaiPhongDAOWSSoapClient();
            return ws.getLoaiPhongbyMaLoai(maloai);
        }
        public static Phong[] getListPhongbyMaLoai(int maloai)
        {
            PhongDAOWSSoapClient ws = new PhongDAOWSSoapClient();
            return ws.getListPhongbyMaLoai(maloai);
        }
        public static bool themPhong(Phong phong)
        {
            PhongDAOWSSoapClient ws = new PhongDAOWSSoapClient();
            if (ws.CheckPhongByTenPhong(phong.TenPhong) == true)
                return false;
            return ws.themPhong(phong);
        }
        public static bool capNhatPhong(Phong phong)
        {
            PhongDAOWSSoapClient ws = new PhongDAOWSSoapClient();
            if (ws.CheckPhongByTenPhong_MaPhong(phong.TenPhong, phong.MaPhong))
                return false;
            return ws.capNhatPhong(phong); 
        }
        public static bool xoaPhong(Phong phong)
        {
            PhongDAOWSSoapClient ws = new PhongDAOWSSoapClient();
            Phong[] dsphongtrong = ws.getListPhongTrong();
            foreach (Phong phg in dsphongtrong)
            {
                if (phong.MaPhong == phg.MaPhong)
                    return ws.xoaPhong(phong);
            } 
            return false;
        } 
    }
}
